import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

/**
 * service 个性化单元
 * @date: 2019-12-23

s
 */
import request from 'utils/request';
import { CPAAS_PLATFORM } from 'utils/config';
import { parseParameters, filterNullValueObject, isTenantRoleLevel, getCurrentOrganizationId } from 'utils/utils';
var prefix = isTenantRoleLevel() ? "".concat(CPAAS_PLATFORM, "/v1/").concat(getCurrentOrganizationId()) : "".concat(CPAAS_PLATFORM, "/v1");
/**
 * 查询所有个性化单元
 */

export function queryList(_x) {
  return _queryList.apply(this, arguments);
}
/**
 * 查询菜单树
 */

function _queryList() {
  _queryList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
    var query;
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            query = filterNullValueObject(parseParameters(params));
            return _context.abrupt("return", request("".concat(prefix, "/customize/unit/list"), {
              query: query
            }));

          case 2:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _queryList.apply(this, arguments);
}

export function queryMenuTree() {
  return _queryMenuTree.apply(this, arguments);
}
/**
 * 创建个性化单元
 */

function _queryMenuTree() {
  _queryMenuTree = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            return _context2.abrupt("return", request("".concat(prefix, "/customize/unit/menu-tree")));

          case 1:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _queryMenuTree.apply(this, arguments);
}

export function createUnit(_x2) {
  return _createUnit.apply(this, arguments);
}
/**
 * 个性化单元详情以及字段配置
 */

function _createUnit() {
  _createUnit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(params) {
    return _regeneratorRuntime.wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            return _context3.abrupt("return", request("".concat(prefix, "/customize/unit"), {
              method: 'POST',
              body: params
            }));

          case 1:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3);
  }));
  return _createUnit.apply(this, arguments);
}

export function queryUnitDetail(_x3) {
  return _queryUnitDetail.apply(this, arguments);
}
/**
 * 修改个性化单元
 *
 */

function _queryUnitDetail() {
  _queryUnitDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(params) {
    return _regeneratorRuntime.wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            return _context4.abrupt("return", request("".concat(prefix, "/customize/unit/detail"), {
              query: params
            }));

          case 1:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4);
  }));
  return _queryUnitDetail.apply(this, arguments);
}

export function modifyUnit(_x4) {
  return _modifyUnit.apply(this, arguments);
}
/**
 * 保存个性化单元字段
 */

function _modifyUnit() {
  _modifyUnit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(params) {
    return _regeneratorRuntime.wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            return _context5.abrupt("return", request("".concat(prefix, "/customize/unit"), {
              method: 'PUT',
              body: params
            }));

          case 1:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  }));
  return _modifyUnit.apply(this, arguments);
}

export function saveUnitField(_x5) {
  return _saveUnitField.apply(this, arguments);
}
/**
 * 获取模型关联的相关模型
 */

function _saveUnitField() {
  _saveUnitField = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(params) {
    return _regeneratorRuntime.wrap(function _callee6$(_context6) {
      while (1) {
        switch (_context6.prev = _context6.next) {
          case 0:
            return _context6.abrupt("return", request("".concat(prefix, "/customize/unit/field-save"), {
              method: 'POST',
              body: params
            }));

          case 1:
          case "end":
            return _context6.stop();
        }
      }
    }, _callee6);
  }));
  return _saveUnitField.apply(this, arguments);
}

export function queryRelationModels(_x6) {
  return _queryRelationModels.apply(this, arguments);
}
/**
 * 删除个性化单元字段
 */

function _queryRelationModels() {
  _queryRelationModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(params) {
    return _regeneratorRuntime.wrap(function _callee7$(_context7) {
      while (1) {
        switch (_context7.prev = _context7.next) {
          case 0:
            return _context7.abrupt("return", request("".concat(prefix, "/customize/model/list/unit"), {
              query: params
            }));

          case 1:
          case "end":
            return _context7.stop();
        }
      }
    }, _callee7);
  }));
  return _queryRelationModels.apply(this, arguments);
}

export function deleteField(_x7) {
  return _deleteField.apply(this, arguments);
}
/**
 * 查询个性化单元分组
 */

function _deleteField() {
  _deleteField = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(params) {
    return _regeneratorRuntime.wrap(function _callee8$(_context8) {
      while (1) {
        switch (_context8.prev = _context8.next) {
          case 0:
            return _context8.abrupt("return", request("".concat(prefix, "/customize/unit/field"), {
              method: 'DELETE',
              query: params
            }));

          case 1:
          case "end":
            return _context8.stop();
        }
      }
    }, _callee8);
  }));
  return _deleteField.apply(this, arguments);
}

export function queryGroup(_x8) {
  return _queryGroup.apply(this, arguments);
}
/**
 * 创建个性化单元分组
 */

function _queryGroup() {
  _queryGroup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(params) {
    return _regeneratorRuntime.wrap(function _callee9$(_context9) {
      while (1) {
        switch (_context9.prev = _context9.next) {
          case 0:
            return _context9.abrupt("return", request("".concat(prefix, "/customize/unit/group"), {
              query: params
            }));

          case 1:
          case "end":
            return _context9.stop();
        }
      }
    }, _callee9);
  }));
  return _queryGroup.apply(this, arguments);
}

export function createGroup(_x9) {
  return _createGroup.apply(this, arguments);
}
/**
 * 修改个性化单元组信息
 */

function _createGroup() {
  _createGroup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(params) {
    return _regeneratorRuntime.wrap(function _callee10$(_context10) {
      while (1) {
        switch (_context10.prev = _context10.next) {
          case 0:
            return _context10.abrupt("return", request("".concat(prefix, "/customize/unit/group"), {
              method: 'POST',
              body: params
            }));

          case 1:
          case "end":
            return _context10.stop();
        }
      }
    }, _callee10);
  }));
  return _createGroup.apply(this, arguments);
}

export function modifyGroup(_x10) {
  return _modifyGroup.apply(this, arguments);
}
/**
 * 查询个性化单元组下的所有个性化单元
 */

function _modifyGroup() {
  _modifyGroup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(params) {
    return _regeneratorRuntime.wrap(function _callee11$(_context11) {
      while (1) {
        switch (_context11.prev = _context11.next) {
          case 0:
            return _context11.abrupt("return", request("".concat(prefix, "/customize/unit/group"), {
              method: 'PUT',
              body: params
            }));

          case 1:
          case "end":
            return _context11.stop();
        }
      }
    }, _callee11);
  }));
  return _modifyGroup.apply(this, arguments);
}

export function queryGroupUnits(_x11) {
  return _queryGroupUnits.apply(this, arguments);
}
/**
 * 复制个性化单元
 */

function _queryGroupUnits() {
  _queryGroupUnits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(params) {
    return _regeneratorRuntime.wrap(function _callee12$(_context12) {
      while (1) {
        switch (_context12.prev = _context12.next) {
          case 0:
            return _context12.abrupt("return", request("".concat(prefix, "/customize/unit/list/group"), {
              query: params
            }));

          case 1:
          case "end":
            return _context12.stop();
        }
      }
    }, _callee12);
  }));
  return _queryGroupUnits.apply(this, arguments);
}

export function copyUnit(_x12) {
  return _copyUnit.apply(this, arguments);
}
/**
 * 获取关联单元的字段配置
 */

function _copyUnit() {
  _copyUnit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(params) {
    return _regeneratorRuntime.wrap(function _callee13$(_context13) {
      while (1) {
        switch (_context13.prev = _context13.next) {
          case 0:
            return _context13.abrupt("return", request("".concat(prefix, "/customize/unit/copy"), {
              method: 'POST',
              body: params
            }));

          case 1:
          case "end":
            return _context13.stop();
        }
      }
    }, _callee13);
  }));
  return _copyUnit.apply(this, arguments);
}

export function queryRelatedUnits() {
  return _queryRelatedUnits.apply(this, arguments);
}

function _queryRelatedUnits() {
  _queryRelatedUnits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
    var params,
        _args14 = arguments;
    return _regeneratorRuntime.wrap(function _callee14$(_context14) {
      while (1) {
        switch (_context14.prev = _context14.next) {
          case 0:
            params = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
            return _context14.abrupt("return", request("".concat(prefix, "/unit-config/unit/related"), {
              query: params,
              method: 'GET'
            }));

          case 2:
          case "end":
            return _context14.stop();
        }
      }
    }, _callee14);
  }));
  return _queryRelatedUnits.apply(this, arguments);
}